<?php if (!defined('THINK_PATH')) exit();?><!DOCTYPE html>
<html>
<head>

	<title></title>
	<script type="text/javascript" charset="utf-8" src="/shop/wwwroot/Public/ueditor/ueditor.config.js"></script>
    <script type="text/javascript" charset="utf-8" src="/shop/wwwroot/Public/ueditor/ueditor.all.min.js"> </script>
    <!--建议手动加在语言，避免在ie下有时因为加载语言失败导致编辑器加载失败-->
    <!--这里加载的语言文件会覆盖你在配置项目里添加的语言类型，比如你在配置项目里配置的是英文，这里加载的中文，那最后就是中文-->
    <script type="text/javascript" charset="utf-8" src="/shop/wwwroot/Public/ueditor/lang/zh-cn/zh-cn.js"></script>
    <script type="text/javascript" src="/shop/wwwroot/Public/jquery-3.3.1/jquery-3.3.1.min.js"></script>
    <link rel="stylesheet" href="/shop/wwwroot/Public/Admin/Styles/goodsAdd.css" type="text/css" />

</head>
<body>

<p align="center">
	<h2>商品添加页</h2>
	<a href="index.html">商品主页</a>
</p>
<p>
	<span class="span1" id="span1">通用属性</span>
	<span class="span2" id="span2">商品属性</span>
</p>
<hr>
<div class="content1" id="content1">
	<form action="../goods/add" enctype="multipart/form-data" method="post">
		商品名称：<input type="text" name="goods_name">
			<span style="color:red;">*</span>
		<br />
		商品货号：<input type="text" name="goods_sn">
		<span style="color:#ccc;">货号可以不填,由系统自动分配</span>
		<br />
		商品分类：<select name="cate_id">
					<option selected="selected">请选择商品分类</option>
					<?php if(is_array($cate_data)): $i = 0; $__LIST__ = $cate_data;if( count($__LIST__)==0 ) : echo "" ;else: foreach($__LIST__ as $key=>$vo): $mod = ($i % 2 );++$i;?><option value="<?php echo ($vo["id"]); ?>">
							|<?php echo (str_repeat("--",$vo["lev"])); echo ($vo["c_name"]); ?>
						</option><?php endforeach; endif; else: echo "" ;endif; ?>
				</select>
				<span style="color:red;">*</span>
		<br />
		<p id="p">
		扩展分类：<input type="button" value="添加扩展分类" id="container_add">
				<select name="cate_ext[]" id="cate_ext">
					<option selected="selected">请选择商品分类</option>
					<?php if(is_array($cate_data)): $i = 0; $__LIST__ = $cate_data;if( count($__LIST__)==0 ) : echo "" ;else: foreach($__LIST__ as $key=>$vo): $mod = ($i % 2 );++$i;?><option value="<?php echo ($vo["id"]); ?>">
							|<?php echo (str_repeat("--",$vo["lev"])); echo ($vo["c_name"]); ?>
						</option><?php endforeach; endif; else: echo "" ;endif; ?>
				</select>
		</p>
		市场价格：<input type="text" name="market_price">
		<span style="color:red;">*</span>
		<br />
		本店价格：<input type="text" name="shop_price">
		<span style="color:red;">*</span>
		<br />
		是否上架：<input type="radio" name="is_sale" value="1" checked="checked">是
				 <input type="radio" name="is_sale" value="0">否
		<br />
		选择属性：
				<input type="checkbox" name="is_hot">推荐
				<input type="checkbox" name="is_rec">热卖
				<input type="checkbox" name="is_new">新品
		<br />
		商品图片：<input type="file" name="goods_img"><span style="color:red;">*</span>
		<br />

		<!-- 加载编辑器的容器 -->
	    
	    <script id="container" name="goods_body" type="text/plain" style="width:1024px;height:400px;" ></script>
		<br />
		<input type="submit" name="提交">
		<input type="reset" name="重置">
	</form>
</div>
<div id="content2" style="display: none;">
	<form action="" enctype="multipart/form-data" method="post">
		<p>
		商品类型:<select name="type_id" id="type_id">
					<option value="0">请选择类型</option>
					<?php if(is_array($type)): $i = 0; $__LIST__ = $type;if( count($__LIST__)==0 ) : echo "" ;else: foreach($__LIST__ as $key=>$vo): $mod = ($i % 2 );++$i;?><option value="<?php echo ($vo["id"]); ?>"><?php echo ($vo["type_name"]); ?></option><?php endforeach; endif; else: echo "" ;endif; ?>
				</select>
		</p>
		<p id="showAttr"></p>
		<p>
			<input type="submit" value="提交">
			<input type="reset">
		</p>
	</form>
</div>

<!-- 实例化编辑器 -->
<script type="text/javascript">
    var ue = UE.getEditor('container');
    $(document).ready(function(){
    	$("#container_add").click(function(){
    		var newSelect = $("#cate_ext").clone(true);
    		$("#p").append(newSelect);
    	});
    });

    //选项卡效果
   	$("#span2").click(function(){
   		$("#content1").hide();
   		$("#content2").show();
   	});
   	$("#span1").click(function(){
   		$("#content1").show();
   		$("#content2").hide();
   	});

   	//选择到属性时候ajax返回数据
   	$("#type_id").change(function(){
   		var type_id = $(this).val();
   		$.ajax({
   			url:"<?php echo U('showAttr');?>",
   			data:{type_id:type_id},
   			type:"post",
   			//返回数据写入到页面中
   			success:function(msg){
   				$("#showAttr").html(msg);
   			}
   		});
   	});
</script>

</body>
</html>